import IconToastComponent from './iconToast.vue'
const IconToast = {};

// 注册Toast
IconToast.install = function (Vue) {

  const ToastConstructor = Vue.extend(IconToastComponent)
  // 生成一个该子类的实例
  const instance = new ToastConstructor();
  function closeSelf() {
    // console.log(instance)
    document.body.removeChild(instance.$el)
    instance.$destroy()


  }


  Vue.prototype.$iconToast = ((msg,cb) => {
    instance.$mount(document.createElement('div'))
    document.body.appendChild(instance.$el)
    instance.msg = msg;

    document.getElementById('toastBtn').onclick = function () {
      closeSelf();
      if(cb){
        cb()
      }

    };


  })
}

export default IconToast
